<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title>按揭单管理</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="statics/css/bootstrap.css">
		<link rel="stylesheet" href="statics/css/bootstrap-datetimepicker.css">
		<script src="https://cdn.bootcss.com/holder/2.9.4/holder.min.js"></script>
		<script type="text/javascript" src="statics/js/jquery.js"></script>
		<script type="text/javascript" src="statics/js/popper.min.js"></script>
		<script type="text/javascript" src="statics/js/bootstrap.js"></script>
		<script type="text/javascript" src="statics/js/bootstrap-datetimepicker.js"></script>
		<script type="text/javascript" src="statics/js/bootstrap-datetimepicker.zh-CN.js"></script>

	</head>

	<body>
		<div class="container">
				<h4 class="page-header">按揭单管理</h4>
			<form action="selectMortgage" method="post">
				<div class="form-inline">
					<label for="customerName">客户姓名</label><input type="text" class="form-control" name="customerName" id="customerName">
					<label for="bankName">按揭机构</label><input type="text" class="form-control" name="bankName" id="bankName">
				</div>
				<div><button class="btn btn-default col-md-offset-4" type="submit" id="selectByNames">查询</button>
					<button class="btn btn-info col-md-offset-1" type="reset">重置</button>
				</div>
			</form>
		</div>

		<div class="container">
			<h4 class="center-block">订单信息</h4>

			<table class="table table-striped table-bordered table-hover table-condensed table-responsive" id="table">
				<tr class="success">
					<th>序号</th>
					<th>操作</th>
					<th>按揭单单号</th>
					<th>客户姓名</th>
					<th>联系电话</th>
					<th>按揭单生成时间</th>
					<th>按揭银行</th>
					<th>按揭单状态</th>
				</tr>
				<#list list as mortgageVO>
					<tr>
					<td>${mortgageVO_index+1}</td>
					<td>
						<a href="alertMortgage?mortgageSheetNo=${mortgageVO.mortgageSheetNo}"><button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal" id="showDetails" >详情</button></a>
						<a href="deleteMortgage?mortgageSheetNo=${mortgageVO.mortgageSheetNo}" class="dele"><button class="btn btn-info">删除</button></a>
						<a href="submitMortage?mortgageSheetNo=${mortgageVO.mortgageSheetNo}" class="sub"><button class="btn btn-info" >提交</button></a>
					</td>
					<td id="mortgageSheetNo">
						${mortgageVO.mortgageSheetNo}
					</td>
					<td>
						${mortgageVO.customerName}
					</td>
					<td>
						${mortgageVO.customerTel}
					</td>
					<td>
						${mortgageVO.mortgageSheetDate}
					</td>
					<td>
						${mortgageVO.bankName}
					</td>
					<td class="state">
						${mortgageVO.mortgageSheetState}
					</td>
					</tr>
				</#list>
			</table>

			<div class=" center-block">
				<button class="btn-info col-sm-1" onclick="javascript:pageNo2(1)">首页</button>
				<button class="btn-info col-sm-1" onclick="javascript:pageNo2(($('#pageNo').val()*1)-1)">上一页</button>
				<button class="btn-info col-sm-1" onclick="javascript:pageNo2(($('#pageNo').val()*1)+1)">下一页</button>
				<button class="btn-info col-sm-1" onclick="javascript:pageNo2($('#thispageTotal').val()*1)">末页</button>
				共<input type="text" value="1" id="thisPageNo" style="width: 10px;border: none" readonly>/<input type="text" id="thispageTotal" value="${pageTotal}" style="width: 10px;border: none" readonly>页
				<input type="hidden" value="1" id="pageNo">
				<span class="col-sm-1"></span></div>
		</div>
<script type="text/javascript">
	$(function () {
        $(".state").each(function (index) {
            if($(this).html()!="已保存" && $(this).html()!="审核驳回"){
                $(this).parent().find(".dele").attr("hidden","hidden");
                $(this).parent().find(".sub").attr("hidden","hidden");
            }
        })
    })
    function pageNo2(pageNo) {
        var customerName = $("#customerName").val();
        var bankName = $("#bankName").val();
        $.getJSON(
            "selectMortgageByJson",
            {"customerName": customerName, "bankName": bankName, "pageNo": pageNo},
            function (data) {
                $("#table tr:not(:first)").remove();
                $(data.list).each(function (index, mortgageVO) {
                    var tr = "<tr><td>" + (index + 1) + "</td><td>"
                        +"<a href='alertMortgage?mortgageSheetNo=" + mortgageVO.mortgageSheetNo + "'" + "><button class='btn btn-info'>详情</button></a>"
							if(mortgageVO.mortgageSheetState =="已保存" || mortgageVO.mortgageSheetState=="审核驳回"){
								tr = tr
                                    + "<a href='deleteMortgage?mortgageSheetNo=" + mortgageVO.mortgageSheetNo + "'" + "><button class='btn btn-info'>删除</button></a>"
                                    + "<a href='submitMortage?mortgageSheetNo=" + mortgageVO.mortgageSheetNo + "'" + "><button class='btn btn-info'>提交</button></a></td>"
							}
                       tr = tr
                        + "<td>" + mortgageVO.mortgageSheetNo + "</td>"
                        + "<td>" + mortgageVO.customerName + "</td>"
                        + "<td>" + mortgageVO.customerTel + "</td>"
                        + "<td>" + mortgageVO.mortgageSheetDate + "</td>"
                        + "<td>" + mortgageVO.bankName + "</td>"
                        + "<td>" + mortgageVO.mortgageSheetState + "</td>";
                    $("#table").append(tr);
                })
                $("#pageNo").val(data.pageNo);
                $("#thisPageNo").val(data.pageNo);
                $("#thispageTotal").val(data.pageTotal);
            }
        )
    }
</script>
</body>
</html>